#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/6/17 10:57
# @Author : 闫峰
# @File    : syclisting.py
import gzip
import json
import pickle
import requests
from retrying import retry

from third_services.WalMart.erp_get_token import get_token_by_erp
from utils.exception.exception import HTTPRequestError
from utils.times_tool.time_control import count_time


class SycListing:

    def create_report(self, orderSourceType, OrderSourceId):
        url = "https://marketplace.walmartapis.com/v3/reports/reportRequests?reportType=ITEM&reportVersion=v4"
        # param = {
        #     "reportType": "ITEM",
        #     "reportVersion": "v4"
        # }
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "Content-Type": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }
        data1 = {
            "rowFilters": [
                {
                    "type": "rangeFilter",
                    "columnName": "Item Last Updated",
                    "from": "2023-10-15",
                    "to": None,
                    "values": None
                },
                {
                    "type": "rangeFilter",
                    "columnName": "Item Last Updated",
                    "from": None,
                    "to": "2023-10-17",
                    "values": None
                }
            ],
            "excludeColumns": None
        }
        res = requests.post(url=url, headers=hearders, json=data1).json()
        print(res)

    def query_status(self, orderSourceType, OrderSourceId, requestId):
        url = f"https://marketplace.walmartapis.com/v3/reports/reportRequests/{requestId}"
        # param = {
        #     "reportType": "ITEM",
        #     "reportVersion": "v4"
        # }
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders).json()
        print(res)

    def download_report(self, orderSourceType, OrderSourceId, requestId):
        url = f"https://marketplace.walmartapis.com/v3/reports/downloadReport?requestId={requestId}"
        # param = {
        #     "reportType": "ITEM",
        #     "reportVersion": "v4"
        # }
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders).json()
        print(res)

    def get_status(self, orderSourceType, OrderSourceId, feedId):
        url = f"https://marketplace.walmartapis.com/v3/feeds/{feedId}?includeDetails=true&offset=0&limit=50"
        # param = {
        #     "reportType": "ITEM",
        #     "reportVersion": "v4"
        # }
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders)
        print(res.json())
        print(json.dumps(res.json()))

    def get_endstatus(self, orderSourceType, OrderSourceId, sku):
        url = f"https://marketplace.walmartapis.com/v3/items/{sku}?productIdType=SKU"
        # param = {
        #     "reportType": "ITEM",
        #     "reportVersion": "v4"
        # }
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders)
        # print(res.json())
        print(json.dumps(res.json(),indent=4))

    def inventory(self, orderSourceType, OrderSourceId):
        url = f"https://marketplace.walmartapis.com/v3/feeds?feedType=inventory"
        param = {
            "inventory": [
                {
                    "quantity": {
                        "amount": 1,
                        "unit": "EACH"
                    },
                    "sku": "200252WS3I0DMZ"
                }
            ],
            "inventoryHeader": {
                "version": "1.4"
            }
        }

        data = {
            "file": json.dumps(param).encode()
        }
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId),
        }

        res = requests.post(url=url, headers=hearders, data=data)
        print(res.json())
        # print(json.dumps(res.json()))

    def get_allitems(self, orderSourceType, OrderSourceId, sku):

        url = f"https://marketplace.walmartapis.com/v3/items?sku={sku}"
        # url = f"https://marketplace.walmartapis.com/v3/items"
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders)
        # print(res.json())
        # print(json.dumps(res.json()))
        if res.status_code == 200:
            return json.dumps(res.json())
        else:
            print(f"接口status_code！=200 res={res.text}")

    def Item_Search(self, orderSourceType, OrderSourceId, gtin):

        url = f"https://marketplace.walmartapis.com/v3/items/walmart/search?gtin={gtin}"
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders)
        # print(res.json())
        # print(json.dumps(res.json()))
        if res.status_code == 200:
            return json.dumps(res.json())
        else:
            print(f"接口status_code！=200 res={res.text}")

    def bulk_item(self, orderSourceType, OrderSourceId,feedType):
        url = f"https://marketplace.walmartapis.com/v3/feeds?feedType={feedType}"
        param = {
            "MPItem": [
                {
                    "Orderable": {
                        "ShippingWeight": 0.33,
                        "brand": "No Brand",
                        "price": 16.65,
                        "productIdentifiers": {
                            "productId": "801113441134",
                            "productIdType": "UPC"
                        },
                        "productName": "20PCS Mini Small Handheld Basket Rattan Woven Small Basket Wedding Holiday Decor",
                        "sku": "40Z113444QCWOD5HA"
                    },
                    "Visible": {
                        "Home Decor, Kitchen, & Other": {
                            "assembledProductHeight": {
                                "measure": 3.14,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 3.14,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 0.33,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 1.96,
                                "unit": "ft"
                            },
                            "color": [
                                "Yellow"
                            ],
                            "compositeWoodCertificationCode": "1 - Does not contain composite wood",
                            "countryOfOriginTextiles": "USA and Imported",
                            "features": [
                                "A great gift for a wedding, house-warming, etc. floral art arrangement.|In addition, this mini flower basket can also stand alone as a decorative piece.|Mini woven basket for flower, its elegant design can go along with various decoration style.|It will add relaxing atmosphere and makes your home warm and lovely.|Suitable for home, office, wedding, party, garden, window sill, gift, desk, restaurant and office."
                            ],
                            "keyFeatures": [
                                "mini woven basket",
                                " mini handheld basket",
                                " flower basket decor",
                                " festival flower basket",
                                " small flower basket"
                            ],
                            "mainImageUrl": "http://picture-cdn04.zhcxkj.com/61307/1/ProductImages/11013547/2021-11-24/723968188ed542d38f5a7144922ebfcb/7897bbb9-3a06-40d3-95f9-8d2ff773f604.jpg",
                            "msrp": 19.98,
                            "productSecondaryImageURL": [
                                "http://picture-cdn04.zhcxkj.com/40342/1/ProductImages/11013547/2021-11-24/2a591a3efd5049e5bbd0be5e8c3657e2/eea48deb-1d13-4a3b-a30b-f3d54e846ba3.jpg",
                                "http://picture-cdn04.zhcxkj.com/27306/1/ProductImages/11013547/2021-11-24/2341193239954299803e3814d3432b34/ca743390-d4b7-40a8-a04c-bc3301f47c7e.jpg",
                                "http://picture-cdn04.zhcxkj.com/60367/1/ProductImages/11013547/2021-11-24/e4026edd2e354ef6a3d5d3974cb3c436/02f4ffa0-9956-4ed8-b339-52a5c99cd207.jpg",
                                "http://picture-cdn04.zhcxkj.com/93145/1/ProductImages/11013547/2021-11-24/99ed0ff22477493090e942ef137c6bbe/e2c4123a-bf13-429e-afad-b5cd96d98185.jpg",
                                "http://picture-cdn04.zhcxkj.com/23767/1/ProductImages/11013547/2021-11-24/6f8eb30e34054d12b95b22cdda6622b9/9e6eb3e5-736d-486e-aa3b-9282d131ab81.jpg"
                            ],
                            "shortDescription": "<strong></strong><strong>Description<br />\n</strong><br />\n<span>Chic and fresh design allow it to blend with any room. It fit as a mini small flower basket, micro landscaping decor, photo props, etc. </span><span>This\n is a perfect gift for your friend who is a mini crafts lover. \nWork great with artificial flowers or silk flowers. adding a \ndecorative accent to your room's decor.<br />\n</span><br />\n<strong>Features</strong><br />\n<br />\n- Color: light yellow.<br />\n- Material: rattan.<br />\n- Size: <span>about 8.00X5.00X5.00cm/3.14X1.97X1.97inch.<br />\n<span>- A great gift for a wedding, house-warming, etc. floral art arrangement.</span><br />\n<span>- In addition, this mini flower basket can also stand alone as a decorative piece.<br />\n<span>- Mini woven </span><span>basket for flower, its e</span><span>legant design can go along with various decoration style.<br />\n- It will add relaxing atmosphere and makes your home warm and lovely.<br />\n</span><span>- Suitable for home, office, wedding, party, garden, window sill, gift, desk, restaurant and office.</span></span></span>",
                            "size": "8x5cm",
                            "smallPartsWarnings": [
                                "0 - No warning applicable"
                            ]
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 0.19,
                        "brand": "No Brand",
                        "price": 8.84,
                        "productIdentifiers": {
                            "productId": "801113441290",
                            "productIdType": "UPC"
                        },
                        "productName": "10Pcs EAS Tags Magnetic Hard Bag Clothing Tags RF Frequency Checkpoint Buckles Anti Retail for Mall Supermarket",
                        "sku": "D3E1134458RFV3NY4"
                    },
                    "Visible": {
                        "Office": {
                            "assembledProductHeight": {
                                "measure": 4.72,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 4.72,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 0.19,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 1.96,
                                "unit": "ft"
                            },
                            "color": [
                                "As Shown"
                            ],
                            "compositeWoodCertificationCode": "1 - Does not contain composite wood",
                            "keyFeatures": [
                                "tags",
                                "anti tags",
                                "supermarket anti buckles",
                                "detacher",
                                "hard tags",
                                "hard detacher",
                                "magnetic detacher",
                                "rf tags",
                                "clothing alarm",
                                "removing ink",
                                "shoes tags",
                                "anti magnetic tags"
                            ],
                            "mainImageUrl": "http://picture-cdn04.zhcxkj.com/99756/1/ProductImages/11013599/2021-06-16/7a1d5395a0674dde84edaf403b073ee4/e062b9c3-e798-474f-951d-becd0af4292f.jpg",
                            "msrp": 10.6,
                            "productSecondaryImageURL": [
                                "http://picture-cdn04.zhcxkj.com/79216/1/ProductImages/11013599/2021-06-16/a536797207f0455ea638eef6aca16311/1e8a1990-eeda-4395-883e-ef0ef2961ead.jpg",
                                "http://picture-cdn04.zhcxkj.com/48674/1/ProductImages/11013599/2021-06-16/14bfabc582a448adb817940e48f251c1/2f61aa44-f463-4198-a0e1-e2dea77ff4ab.jpg",
                                "http://picture-cdn04.zhcxkj.com/62133/1/ProductImages/11013599/2022/08/30/04d8ffdccab8497190443053c13ad26e/bfc0a33c-58ca-4ae6-8a8c-797498107d99.jpg",
                                "http://picture-cdn04.zhcxkj.com/48027/1/ProductImages/11013599/2022/08/30/899dfa25b4f74a2f937a3d94b7364f11/34460658-e29b-4088-864c-32a089915740.jpg",
                                "http://picture-cdn04.zhcxkj.com/93421/1/ProductImages/11013599/2022/08/30/29520898764e41b78893c444d7c68b13/65a011c2-0ca0-4921-b406-d2fd2b235591.jpg"
                            ],
                            "shortDescription": "<b> Description</b><br /><br /> Are you still worried that the commodity in the store will be stolen? Well, you must not miss our tags. Adoption of premium and durable material, they are safe and durable. shopping malls, clothing shops, luggage stores, etc.<br /><br /><b> Features</b><br /><br />- Color:.<br />- Material:.<br />- Size: About 12. 00X5. 00X1. 50cm/ 4. 72X1. 97X0. 59inch.<br />- You will receive 10 tags to meet your daily requirements.<br />- Suitable for supermarkets, shopping malls, and stores.<br />- It can effectively the loss and of bag, luggage, jewelry, and much.<br />- High- quality material and fine craftsmanship, durable and sturdy for a long time.<br />- Effectively exerts the function of anti- buckle, which is practical and functional.<br /><br />- Color: As Shown.<br />- Size: 12X5X1. 5CM.",
                            "size": "12X5X1.5CM",
                            "smallPartsWarnings": [
                                "0 - No warning applicable"
                            ]
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 0.94,
                        "brand": "No Brand",
                        "price": 17.71,
                        "productIdentifiers": {
                            "productId": "801113441666",
                            "productIdType": "UPC"
                        },
                        "productName": "6Pcs Self-Adhesive Wall Wire Raceway Cable Storage Hubs Office Cable Organizer",
                        "sku": "4FM11344421I9RT5G"
                    },
                    "Visible": {
                        "Electronics Accessories": {
                            "assembledProductHeight": {
                                "measure": 11.22,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 11.22,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 0.94,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 3.03,
                                "unit": "ft"
                            },
                            "color": [
                                "Blue"
                            ],
                            "features": [
                                "Adoption of premium material, this product is practical, sturdy and long-time use.|With the cover design, the wire is not exposed outside, use more assured.|Stick to the ground can prevent trampling damage to wire.|Convenient to organize various routes in daily life.|Multi-card slot design can be placed at the same time more than one wire, line orderly."
                            ],
                            "keyFeatures": [
                                "Cable Storage Hub",
                                " Wall Wire Raceway",
                                " Network Cable Receiving Hub",
                                " Wire Storage Box",
                                " Cable Organizer"
                            ],
                            "mainImageUrl": "http://picture-cdn03.zhcxkj.com/40587/1/ProductImages/11013645/2021-06-09/7720b366b0044631a42c24b066426be8/638be463-0ef6-4389-97f0-05876f3d9be7.jpg",
                            "msrp": 21.25,
                            "productSecondaryImageURL": [
                                "http://picture-cdn03.zhcxkj.com/99346/1/ProductImages/11013645/2021-06-09/05a4041e19884d318b217b8fa213686c/a672e881-688d-437e-85f2-37c557f18e38.jpg",
                                "http://picture-cdn03.zhcxkj.com/95378/1/ProductImages/11013645/2021-06-09/1f9d02b89e9e4505a3c434cbf9ed9ec7/6e5874a5-5e93-43b4-891a-2c4c610b5001.jpg",
                                "http://picture-cdn03.zhcxkj.com/17550/1/ProductImages/11013645/2021-06-09/b8d2965887b1457ab6d0c91dffa43b65/c81c8324-4318-416e-b273-c8b707c95b23.jpg",
                                "http://picture-cdn03.zhcxkj.com/86428/1/ProductImages/11013645/2021-06-09/6658960f137c42e9b051fc2111e859f8/adc06a52-180e-4eb2-958e-4749c0c58d5f.jpg",
                                "http://picture-cdn03.zhcxkj.com/80099/1/ProductImages/11013645/2021-06-09/5035b0899dde450e8f6a0ac482001bec/d95389f1-c3c0-4750-a53c-ee03882b60bc.jpg"
                            ],
                            "shortDescription": "<strong>Description</strong><br />\n<span>Tired of those messy cables and cords around your desk, TV, computer or cell phone? These cable fixing clips will solve your problem and will make sure that your cables are organized and easy accessible for you when you need them.&nbsp;With durable and long-lasting material, this eco-friendly organizer will easily organize your cable.</span><br />\n<strong>Features</strong><br />\n<br />\n-Color: White &amp; Blue&nbsp;<br />\n-Material:&nbsp;PP<br />\n-Size: Approx.&nbsp;<span>28.50X7.70X1.00cm /&nbsp;<span>11.20X3.03X0.39in<br />\n<span>- Adoption of premium material, this product is practical, sturdy and long-time use.</span><br />\n<span>- With the cover design, the wire is not exposed outside, use more assured.</span><br />\n<span>- Stick to the ground can prevent trampling damage to wire.</span><br />\n<span>- Convenient to organize various routes in daily life.</span><br />\n<span>- Multi-card slot design can be placed at the same time more than one wire, line orderly.</span></span></span>",
                            "size": "28.5X7.7X1CM"
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 19.44,
                        "brand": "No Brand",
                        "price": 203.56,
                        "productIdentifiers": {
                            "productId": "801113441404",
                            "productIdType": "UPC"
                        },
                        "productName": "171pcs Socket Wrench Car repair Drive Socket Set for DIY Car Motorcycle Repair",
                        "sku": "00O113448F65MY4WB"
                    },
                    "Visible": {
                        "Vehicle Parts & Accessories": {
                            "assembledProductHeight": {
                                "measure": 10.23,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 10.23,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 19.44,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 1.77,
                                "unit": "ft"
                            },
                            "color": [
                                "Assorted Color"
                            ],
                            "compositeWoodCertificationCode": "1 - Does not contain composite wood",
                            "features": [
                                "materials and good craftsmanship ensure its durability and practicality.|Tools are neatly stored in a case, keep them secure, clean, organized and easy to find..| handyman\u2019s, repairmen, construction workers, mechanics, body shops etc.|It is also a good gift choice for family member, friends, partners, etc.|The tool kit is equipped with 171 other_project, which can meet different needs."
                            ],
                            "keyFeatures": [
                                "Car Tool Kit",
                                " Car Repair Tool Set",
                                " Car Tool Socket Kit",
                                " Repair Tool Set for Car",
                                " Car Tool Box Kit"
                            ],
                            "mainImageUrl": "http://picture-cdn.zhcxkj.com/43457/1/ProductImages/11013690/2021-06-04/d3511e1f8bb64204bdbf6a23891d6cc8/ec1ff44c-5895-43d5-81ab-377e182d039a.jpg",
                            "msrp": 244.27,
                            "productSecondaryImageURL": [
                                "http://picture-cdn.zhcxkj.com/42718/1/ProductImages/11013690/2021-06-04/684a9ea906684e62abe80ed0e6f888c7/597db523-360e-4dbc-89ee-005f3d4e9cb4.jpg",
                                "http://picture-cdn.zhcxkj.com/58133/1/ProductImages/11013690/2021-06-04/28bac6baa1c8478cbeff27f7f76bc8a8/922683f1-b52a-44d4-aff8-83447a88de45.jpg",
                                "http://picture-cdn.zhcxkj.com/34879/1/ProductImages/11013690/2021-06-04/be229cd34d3441b197ab31850364687b/a173d850-6fd9-488d-8253-e5a3bf7bc031.jpg",
                                "http://picture-cdn.zhcxkj.com/50949/1/ProductImages/11013690/2021-06-04/9c41fe9dcaac4e958a4edb9ff66f49c5/33d69077-b419-485a-aa79-61efbecc1bfb.jpg",
                                "http://picture-cdn.zhcxkj.com/70222/1/ProductImages/11013690/2021-06-04/bc58892334bd44808d4be0ba58b8d2ff/93c4fc8c-14e7-4a0b-9815-dea06aa6bb8d.jpg"
                            ],
                            "shortDescription": "<strong>Description<br />\n</strong><br />\nThis is a general car repair tool kit, which is made of materials and has a long service life. This tool kit has a variety of other_project, such as wrenches, sockets, etc. This home tool kit can meet your different using needs.<br />\n<br />\n<strong>Features</strong><br />\n<br />\n-Color: <span>Assorted.</span><br />\n-Material: ABS, high carbon steel.<br />\n-Size: About <span>26.00X4.50X3.70cm/</span><span>10.22X1.77X1.45in.<br />\n- materials and good craftsmanship ensure its durability and practicality.<br />\n<span>- </span>Tools are neatly stored in a case, keep them secure, clean, organized and easy to find..<br />\n<span>- </span> handyman\u2019s, repairmen, construction workers, mechanics, body shops etc.<br />\n<span>- </span>It is also a good gift choice for family member, friends, partners, etc.<br />\n<span>- </span>The tool kit is equipped with 171 other_project, which can meet different needs.<br />\n</span>",
                            "size": "26X4.5cm"
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 0.33,
                        "brand": "No Brand",
                        "price": 13.89,
                        "productIdentifiers": {
                            "productId": "801113441947",
                            "productIdType": "UPC"
                        },
                        "productName": "3Pcs Wooden Nail Brush Nail Hand Scrubbing Fingernail Cleaning Brush Cleaner",
                        "sku": "WM4113449T89CMC5R"
                    },
                    "Visible": {
                        "Beauty, Personal Care, & Hygiene": {
                            "assembledProductHeight": {
                                "measure": 3.34,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 3.34,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 0.33,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 1.77,
                                "unit": "ft"
                            },
                            "color": [
                                "burlywood"
                            ],
                            "features": [
                                "The nail brush is made of materials, which is sturdy, smooth and comfortable. |The bristles are made of flexible natural material, and hard moderate, easy to clean dirt inside the nail gap and won't scratch your skin. |These brushes are remover dirt from hand, fingertip and foot, also can be used in the kitchen, bathroom, garden shed sink.|Double side design, one side clean dirt under the fingernails/on the face of toes fingers nail, on the other side clean hands or feet, the of nails and other place. |Package includes 3 pieces of brushes, enough quantity for your daily using, replacing and sharing."
                            ],
                            "keyFeatures": [
                                "Nail Brushes",
                                " Two Sided Boar Bristle Brush",
                                " Wooden Manicure Brush",
                                " Pedicure Hand Brush",
                                " Nail Pedicure Tool"
                            ],
                            "labelImage": [
                                {
                                    "labelImageContains": "No Label"
                                }
                            ],
                            "mainImageUrl": "http://picture-cdn02.zhcxkj.com/41760/1/ProductImages/11013699/2021/6/4/9ddf64dd8dde4f299b3d5c5c80d471ed/4e314c01-df66-9d3d-e1bf-118bc5be2145.jpg",
                            "msrp": 16.66,
                            "productSecondaryImageURL": [
                                "http://picture-cdn02.zhcxkj.com/31743/1/ProductImages/11013699/2021-06-03/caf9b2157e6b4c5a8d4176a1b6685ac3/dd853587-335f-4329-be3e-2f8d7c6bfaf7.jpg",
                                "http://picture-cdn02.zhcxkj.com/83902/1/ProductImages/11013699/2021-06-03/14287f786f474362bc8af08f98bdfa80/070dabc4-1190-4558-989b-1651b76864e9.jpg",
                                "http://picture-cdn02.zhcxkj.com/70859/1/ProductImages/11013699/2021-06-03/94efbc82beca4e68a4c790c69281f335/82068529-ebff-4063-906b-6e7ef441d22d.jpg",
                                "http://picture-cdn02.zhcxkj.com/33687/1/ProductImages/11013699/2021/6/4/e7fe63ca0aae4cb7b7c8deb0556b3bfa/6336d9f3-01f3-5716-d071-89a3ee19d281.jpg",
                                "http://picture-cdn02.zhcxkj.com/40993/1/ProductImages/11013699/2021-06-03/f63ee503a8994071be4625fbad9f225e/d54dbdf3-440b-4855-8e2a-201ebb69b576.jpg"
                            ],
                            "shortDescription": "<strong>Description</strong><br />\n<br />\n<span>This nail brush is used to wash nails. The brush is made of \n materials and is durable. Small size, light and portable. \nNot only can it be used as a nail cleaner, it can also be used to clean \ncrevices in your home. In addition, you can put it in your luggage when \nyou travel, in case you need it.</span><br />\n<br />\n<strong>Features</strong><br />\n<br />\n- Color: Burlywood<br />\n- Material: <span class=\"VIiyi\"><span class=\"JLqJ4b ChMk0b\"><span>Beech, white bristles</span></span></span><br />\n- Size: 8.50X4.50X4.50cm/3.34X1.77X1.77inch.<br />\n- The nail brush is made of materials, which is sturdy, smooth and comfortable. <br />\n- The bristles are made of flexible natural material, and hard moderate, easy to clean dirt inside the nail gap and won't scratch your skin. <br />\n- These brushes are remover dirt from hand, fingertip and foot, also can be used in the kitchen, bathroom, garden shed sink.<br />\n- Double side design, one side clean dirt under the fingernails/on the face of toes fingers nail, on the other side clean hands or feet, the of nails and other place. <br />\n- Package includes 3 pieces of brushes, enough quantity for your daily using, replacing and sharing.",
                            "size": "8.5x4.5m"
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 0.17,
                        "brand": "No Brand",
                        "price": 9.82,
                        "productIdentifiers": {
                            "productId": "801113441273",
                            "productIdType": "UPC"
                        },
                        "productName": "20Pcs Toothbrush Covers Compatible with Toothbrush Heads (Transparent)",
                        "sku": "S3O113449G2I3VH8W"
                    },
                    "Visible": {
                        "Beauty, Personal Care, & Hygiene": {
                            "assembledProductHeight": {
                                "measure": 1.18,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 1.18,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 0.17,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 0.82,
                                "unit": "ft"
                            },
                            "color": [
                                "transparent"
                            ],
                            "features": [
                                "They fit the toothbrush heads well, do not fall off, and are easy to use.|Suitable for traveling, camping, hiking or business trip.|No matter where you go, you always carry a clean toothbrush.|Protect the toothbrush head from dust, stains, etc.|These protective caps can be given to friends or family as gifts."
                            ],
                            "keyFeatures": [
                                "Dustproof Cover",
                                " Toothbrush Lid",
                                " Protective Cover",
                                " Travel Brush Cover",
                                " Toothbrush Head Cover",
                                " Toothbrush Accessories"
                            ],
                            "labelImage": [
                                {
                                    "labelImageContains": "No Label"
                                }
                            ],
                            "mainImageUrl": "http://picture-cdn.zhcxkj.com/87238/1/ProductImages/11013729/2021-06-11/a313c26fcc3141fd89e5e254c0f89aa1/a635bc6c-3f97-47d8-9fc5-bc1609a91a6a.jpg",
                            "msrp": 11.78,
                            "productSecondaryImageURL": [
                                "http://picture-cdn.zhcxkj.com/90908/1/ProductImages/11013729/2021-06-11/26418bf006bd47fe9f3ccf530a800877/ec1b75d4-2935-4b53-8c4c-7645e4a8f1f2.jpg",
                                "http://picture-cdn.zhcxkj.com/68449/1/ProductImages/11013729/2021-06-11/6abf9a04685145b99fef5557d03b3bd1/8780a881-d56a-48b1-a068-a2a3474719d5.jpg",
                                "http://picture-cdn.zhcxkj.com/20398/1/ProductImages/11013729/2021-06-11/3f71b257ca4c4c549ef62c592c481f48/1ac0bdad-5d70-4f8e-8b8d-c58dc77ce63c.jpg",
                                "http://picture-cdn.zhcxkj.com/82685/1/ProductImages/11013729/2021-06-11/19b0fcff04c24ca2ba4b40fd1195604c/4d95ef01-b39b-4cbf-8936-9793299d2a5f.jpg",
                                "http://picture-cdn.zhcxkj.com/84501/1/ProductImages/11013729/2021-06-11/7e77bb15128847e793bb4f9e905a1958/dffc640a-3319-41c0-8552-f0380c33a4a0.jpg"
                            ],
                            "shortDescription": "<strong>Description</strong><br />\n<br />\nThese are 20 toothbrush head covers, which are made of materials and are durable. The compact size design saves space and is easy to carry. Very suitable for travel, outdoor, camping, etc. You can easily put them in your bag.<br />\n<br />\n<strong>Features</strong><br />\n<br />\n<span>-Color: Transparent.</span><br />\n<span>-Material: </span><span>Resin.</span><br />\n<span>-Size: About </span><span>3.00X2.10X1.50cm/ 1.18X0.83X0.59in.<br />\n</span>- They fit the toothbrush heads well, do not fall off, and are easy to use.<br />\n- Suitable for traveling, camping, hiking or business trip.<br />\n- No matter where you go, you always carry a clean toothbrush.<br />\n- Protect the toothbrush head from dust, stains, etc.<br />\n- These protective caps can be given to friends or family as gifts.<br />",
                            "size": "3X2.1X1.5CM"
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 2.2,
                        "brand": "No Brand",
                        "price": 32.27,
                        "productIdentifiers": {
                            "productId": "801113441194",
                            "productIdType": "UPC"
                        },
                        "productName": "1Set Household Screwdriver Lithium Rechargeable Electric Screwdriver Drill Bits",
                        "sku": "I5911344973P805ZE"
                    },
                    "Visible": {
                        "Tools": {
                            "assembledProductHeight": {
                                "measure": 6.1,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 6.1,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 2.2,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 5.51,
                                "unit": "ft"
                            },
                            "color": [
                                "Black"
                            ],
                            "features": [
                                "It is delivered with screwdriver, charging cable and drill bit set.|Adopted of quality material with fine workmanship, they are durable and strong.|Rechargeable lithium battery powered, cordless and convenient to use. Easy to change the direction of rotating by pressing the button.| fixing screws, installing light fixtures, constructing furniture and more.|The compact body has strong power for easy intricate work. Suitable for home, office, DIY, etc."
                            ],
                            "inflexKitComponent": "No",
                            "keyFeatures": [
                                "rechargeable electric screwdriver",
                                " mini drill kit",
                                " cordless drill driver set",
                                " electric screw driver",
                                " rechargeable drill cordless set"
                            ],
                            "mainImageUrl": "http://picture-cdn04.zhcxkj.com/22057/1/ProductImages/11013735/2021-06-03/3f0334ae43e14ec5842769968e7ea55c/9efa45c4-e3c9-4893-a8d3-c32fbdadbd11.jpg",
                            "msrp": 38.72,
                            "productSecondaryImageURL": [
                                "http://picture-cdn04.zhcxkj.com/82455/1/ProductImages/11013735/2021-06-03/2bfdb40dd81b49b38f279707a924c375/453a2724-28c8-4793-ad70-22ffa889c149.jpg",
                                "http://picture-cdn04.zhcxkj.com/97560/1/ProductImages/11013735/2021-06-03/31d49ee668ec462abecba5beaa18dea2/070df373-b36e-4a6d-a249-45e79b105e83.jpg",
                                "http://picture-cdn04.zhcxkj.com/23664/1/ProductImages/11013735/2021-06-03/adb84dbee7db4d1ea229091b97568647/ccbbbfaa-f753-4bf6-b5ee-4d40a6f81b2d.jpg",
                                "http://picture-cdn04.zhcxkj.com/39078/1/ProductImages/11013735/2021-06-03/83b36a6e8bb243849bd29c38ab35532e/dc032209-c68d-467d-8351-904391b383cb.jpg",
                                "http://picture-cdn04.zhcxkj.com/56347/1/ProductImages/11013735/2021-06-03/50356c04ebe54f1bb0ca1c692f718d1c/4ab3d529-dc77-429e-8067-6b1581cf6782.jpg"
                            ],
                            "shortDescription": "<strong>Description</strong><br />\n<br />\nThis rechargeable electric screwdriver, made of premium material \nwith fine workmanship, is practical and durable. Include a set of drill \nbits and charging cable, easy to use. repair or installation \nwork. Suitable for home, office, shop, etc. A must-have in your tool \nbox.<br />\n<br />\n<strong>Features</strong><br />\n<br />\n- Color: Black<br />\n- Material: <span class=\"VIiyi\"><span class=\"JLqJ4b ChMk0b\"><span>Plastic, stainless steel, motor</span></span></span><br />\n- Size: 15.50X14.00X4.00cm/6.09X5.50X1.57inch.<br />\n- Note: The color of the accessories is sent randomly. <br />\n- It is delivered with screwdriver, charging cable and drill bit set.<br />\n- Adopted of quality material with fine workmanship, they are durable and strong.<br />\n- Rechargeable lithium battery powered, cordless and convenient to use. Easy to change the direction of rotating by pressing the button.<br />\n- fixing screws, installing light fixtures, constructing furniture and more.<br />\n- The compact body has strong power for easy intricate work. Suitable for home, office, DIY, etc.",
                            "size": "15.5x14cm"
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 0.16,
                        "brand": "No Brand",
                        "price": 9.42,
                        "productIdentifiers": {
                            "productId": "080111341470",
                            "productIdType": "UPC"
                        },
                        "productName": "4 Pcs Children Drum Stick Rainbow Color Drum Sticks Percussion Drumsticks",
                        "sku": "PXY113448K0MK062K"
                    },
                    "Visible": {
                        "Instrument Accessories": {
                            "assembledProductHeight": {
                                "measure": 8.26,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 8.26,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 0.16,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 1.37,
                                "unit": "ft"
                            },
                            "color": [
                                "Rainbow color"
                            ],
                            "compositeWoodCertificationCode": "1 - Does not contain composite wood",
                            "features": [
                                "The item is manufactured with premium material for durable and reusable use.|The ergonomic design makes it comfortable to hold.|A good early musical educational toy for kids. |With fine craftsmanship, pretty convenient to carry for the party performance.| musical enthusiast or children to practice the drum."
                            ],
                            "keyFeatures": [
                                "Percussion Drumsticks",
                                " Plastic Drum Sticks",
                                " Drumsticks",
                                " Drum Accessories",
                                " Percussion Drum Tool"
                            ],
                            "mainImageUrl": "http://picture-cdn02.zhcxkj.com/79561/1/ProductImages/11013847/2021-06-16/6756e2e78dfd40939348d037e3abdc9f/210c498f-2e03-4464-8696-46cdf4648c81.jpg",
                            "msrp": 11.3,
                            "productSecondaryImageURL": [
                                "http://picture-cdn02.zhcxkj.com/88869/1/ProductImages/11013847/2021-06-16/d5ed992045ff4538bb7a8b05d4c1afa3/22394ce3-aa8e-455d-892f-6719f05982d5.jpg",
                                "http://picture-cdn02.zhcxkj.com/87319/1/ProductImages/11013847/2021-06-16/608bce5d596c4f64b22a5564545811a8/25793d0e-6aa5-4e6c-9a8a-e8fbc594c3d2.jpg",
                                "http://picture-cdn02.zhcxkj.com/48119/1/ProductImages/11013847/2021-06-16/b22184c429ba4a0c8dd906c1f3d52886/68dfde86-8d4c-4486-a42e-d38f737f4fc0.jpg",
                                "http://picture-cdn02.zhcxkj.com/85369/1/ProductImages/11013847/2021-06-16/d0641672443d4ee39c59d96ceaeeb3de/7349e88f-ca6c-492e-bc42-d9a28ee90c1f.jpg",
                                "http://picture-cdn02.zhcxkj.com/46775/1/ProductImages/11013847/2021-06-16/1f75c3d6e20e45bdb88dbeeb510d643a/d1c6b27d-a4e7-4004-8955-1b1c928992b2.jpg"
                            ],
                            "shortDescription": "<strong>Description</strong><br />\n<br />\nThe children drumsticks are manufactured with materials, which is comfortable to grip, making you enjoy the drum performing and show your musical talent. They are suitable for drums of various musical styles and beginners, students.<br />\n<br />\n<strong>Features</strong><br />\n<br />\n-Color: <span>Rainbow color</span><br />\n-Material: EVA sponge, plastic<br />\n-Size: About <span>21.00X3.50X1.50cm/<span>8.25X1.38X0.59inch<br />\n- The item is manufactured with premium material for durable and reusable use.<br />\n- The ergonomic design makes it comfortable to hold.<br />\n- A good early musical educational toy for kids. <br />\n- With fine craftsmanship, pretty convenient to carry for the party performance.<br />\n- musical enthusiast or children to practice the drum.<br />\n</span></span>",
                            "size": "21X3.5X1.5CM",
                            "smallPartsWarnings": [
                                "0 - No warning applicable"
                            ]
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 0.11,
                        "brand": "No Brand",
                        "price": 9.04,
                        "productIdentifiers": {
                            "productId": "801113441911",
                            "productIdType": "UPC"
                        },
                        "productName": "2pcs Laboratory Inoculation Stick Experiment Inoculation Needle Inoculation Ring",
                        "sku": "U3M1134528ZJI6R8J"
                    },
                    "Visible": {
                        "Building Supply": {
                            "assembledProductHeight": {
                                "measure": 8.66,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 8.66,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 0.11,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 0.27,
                                "unit": "ft"
                            },
                            "color": [
                                "As Shown"
                            ],
                            "compositeWoodCertificationCode": "1 - Does not contain composite wood",
                            "features": [
                                "It is also very simple to replace the inoculating loop, whether it is applied in the laboratory or in the classroom.|Fine workmanship and great texture, not only stable but also durable.|The kit with sufficient quantity to meet your requirements.|The inoculation rod is made of pure copper, the handle is plastic, and has good insulation performance.\u200b|The replacement inoculating ring uses premium material for durability and long-lasting use."
                            ],
                            "keyFeatures": [
                                "Microbiology Inoculation Rod",
                                " Laboratory Tool",
                                " Laboratory Parts",
                                " Laboratory Tool Supply",
                                " Laboratory Device"
                            ],
                            "mainImageUrl": "http://picture-cdn.zhcxkj.com/77017/1/ProductImages/11013966/2022/08/24/d78972be54a745269cee667ad769e1bd/8c90aaf3-8f17-484c-84d6-63300572b938.jpg",
                            "msrp": 10.84,
                            "productSecondaryImageURL": [
                                "http://picture-cdn.zhcxkj.com/70786/1/ProductImages/11013966/2021-06-08/ef473e5bc83741978f6c811f3608d0f3/9c82fbaf-5507-41fa-921a-a4ef88c51dc3.jpg",
                                "http://picture-cdn.zhcxkj.com/93226/1/ProductImages/11013966/2023/02/04/b4e1c4ee05a848f1916ef39110d2fc8b/d948eaca-6033-4d15-a758-e1f102a1e5d8.jpg",
                                "http://picture-cdn.zhcxkj.com/68112/1/ProductImages/11013966/2021-06-08/fd38d3af787b4b029e40092a62352aeb/d4d75735-9ef7-4069-a6a4-1e430515c3de.jpg",
                                "http://picture-cdn.zhcxkj.com/45367/1/ProductImages/11013966/2022/08/24/31ea690d6df54a21bbbeb25b7d89a672/13e5efbd-e6ac-4d40-bb3f-c4452673d093.jpg",
                                "http://picture-cdn.zhcxkj.com/20307/1/ProductImages/11013966/2022/08/24/7dfd47cb2bf044c58c4c09030a0f01c9/1952b30c-c804-491a-a197-d8dd14feec1a.jpg"
                            ],
                            "shortDescription": "<strong>Description</strong><br />\n<br />\nThese inoculating feature small size and light weight, easy to control the balance and operate in your experiment operation, providing you with simple use. Inoculation are made of materials with good stability, heat and corrosion resistance, which can be cleaned at high temperature. <br />\n<br />\n<strong>Features</strong><br />\n<br />\n-Color:<span>Random Color </span><br />\n-Material:Copper and plastic <br />\n- Size: 22.00X0.70X0.70cm/8.65X0.28X0.28in <br />\n<br />\n-It is also very simple to replace the inoculating loop, whether it is applied in the laboratory or in the classroom.<br />\n-Fine workmanship and great texture, not only stable but also durable.<br />\n-The kit with sufficient quantity to meet your requirements.<br />\n-The inoculation rod is made of pure copper, the handle is plastic, and has good insulation performance.<br />\n-The replacement inoculating ring uses premium material for durability and long-lasting use.<br />",
                            "size": "19X1X1CM"
                        }
                    }
                },
                {
                    "Orderable": {
                        "ShippingWeight": 0.59,
                        "brand": "No Brand",
                        "price": 13.25,
                        "productIdentifiers": {
                            "productId": "080111344129",
                            "productIdType": "UPC"
                        },
                        "productName": "2Pcs 90mm Laboratory Glass Flask Rubber Base Holders Flask Rest (Random Color)",
                        "sku": "98K113452QEBU6YK1"
                    },
                    "Visible": {
                        "Building Supply": {
                            "assembledProductHeight": {
                                "measure": 3.54,
                                "unit": "ft"
                            },
                            "assembledProductLength": {
                                "measure": 3.54,
                                "unit": "ft"
                            },
                            "assembledProductWeight": {
                                "measure": 0.59,
                                "unit": "lb"
                            },
                            "assembledProductWidth": {
                                "measure": 3.54,
                                "unit": "ft"
                            },
                            "color": [
                                "As Shown"
                            ],
                            "compositeWoodCertificationCode": "1 - Does not contain composite wood",
                            "features": [
                                "The product is lightweight, with strong flexibility and non- flammable.|Used for holding your flasks or other spherical bottom containers from failing easily.|It has a simple design, but very practical in use, bring much convenience to you.|Suitable for student and teacher do experiment with flask.|It is manufactured with top-class material for durable and long-lasting use."
                            ],
                            "keyFeatures": [
                                "Laboratory Flask Pad",
                                " Flask Seat",
                                " Rubber Flask Stand",
                                " Round Bottom Flask Stand",
                                " Flask Bottom Holders"
                            ],
                            "mainImageUrl": "http://picture-cdn04.zhcxkj.com/41558/1/ProductImages/11014045/2021-06-08/19fdb588336b447486df4fe6f751d651/8a020ad5-9519-4217-adbc-4bbfac4c3e2c.jpg",
                            "msrp": 15.9,
                            "productSecondaryImageURL": [
                                "http://picture-cdn04.zhcxkj.com/48182/1/ProductImages/11014045/2021-06-08/0b61964affef4777b9a362a8dfd6c1ef/1ce37ed9-26e0-4cd0-94ca-231e4c16d49d.jpg",
                                "http://picture-cdn04.zhcxkj.com/90629/1/ProductImages/11014045/2021-06-08/75bea7a537c64bca98b219d7366fb60b/1b81cab4-b1b7-43f9-ac2a-c48ef0a65a62.jpg",
                                "http://picture-cdn04.zhcxkj.com/26556/1/ProductImages/11014045/2021-06-08/28221cc28fea43ba98807f1dc3387b80/8d34b5b9-5da2-43b0-900a-2104c230427f.jpg",
                                "http://picture-cdn04.zhcxkj.com/42364/1/ProductImages/11014045/2021-06-08/1180c0b3c62b4cc7a8c7e3ab900d3216/786590bb-33b1-4e6f-9ab0-e491b37aa78a.jpg",
                                "http://picture-cdn04.zhcxkj.com/32115/1/ProductImages/11014045/2021-06-08/ef328e0a6a6347d68f41ccb84f6002e2/97440b62-d4d3-49e7-bdff-f9b35cfa8872.jpg"
                            ],
                            "shortDescription": "<strong>Description</strong><br />\n<br />\nFlask support firmly holds round bottom flasks. We use material the surface is smooth, and after fine treatment the \ntoughness is strong. The special structure and composition make the product \nhave a series of special properties. <br />\n<br />\n<strong>Features</strong><br />\n<br />\n- Color: Random color.<br />\n- Material: Rubber.<br />\n- Size: About 9.00X9.00X5.50cm/ 3.54X3.54X2.16inch.<br />\n<span><span>- The product is lightweight, with strong flexibility and non- flammable.<br />\n<span>- Used for holding your flasks or other spherical bottom containers from failing easily.<br />\n- It has a simple design, but very practical in use, bring much convenience to you.<br />\n- Suitable for student and teacher do experiment with flask.<br />\n- It is manufactured with top-class material for durable and long-lasting use.</span></span></span><br />",
                            "size": "9X9X5.5CM"
                        }
                    }
                }
            ],
            "MPItemFeedHeader": {
                "locale": "en",
                "processMode": "REPLACE",
                "sellingChannel": "marketplace",
                "subset": "EXTERNAL",
                "version": "4.8"
            }
        }
        update_param = {
          "MPItemFeedHeader": {
            "sellingChannel": "mpmaintenance",
            "processMode": "REPLACE",
            "subset": "EXTERNAL",
            "locale": "en",
            "version": "4.8",
            "subCategory": "computers"
          },
          "MPItem": [
            {
              "Orderable": {
                "sku": "6050538&Vero1109",
                "productIdentifiers": {
                  "productIdType": "GTIN",
                  "productId": "03121177386463"
                },
                "productName":"16.5x10cm 5Pcs Lovely Cartoon Cat  Sticker Refrigerator Sticker Black"
              },
              "Visible": {
                "Computers": {
                }
              }
            }
          ]
        }

        data = {
            "file": json.dumps(update_param).encode()
        }
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId),
        }

        res = requests.post(url=url, headers=hearders, files=data)
        print(res.json())
        # print(json.dumps(res.json()))

    def promotion(self, orderSourceType, OrderSourceId, sku):
        url = f"https://marketplace.walmartapis.com/v3/feeds?feedType=promo"
        param = """
        <?xml version="1.0" encoding="UTF-8" standalone="no"?>
        PriceFeed xmlns="http://walmart.com/">\n
            <PriceHeader>\n
                <version>1.5.1</version>\n
            </PriceHeader>\n
            <Price>\n
                <itemIdentifier>\n
                    <sku>12027865@EeaWAR0829</sku>\n
                </itemIdentifier>\n
                <pricingList replaceAll="false">\n
                    <pricing effectiveDate="2023-08-31T20:00:00.000Z" expirationDate="2023-12-31T20:00:00.000Z" processMode="DELETE" promoId="a46cba7f-bbb0-40d5-865b-37b9aeafcc0c">\n
                        <currentPrice>\n
                            <value amount="22.79" currency="USD"/>\n
                        </currentPrice>\n
                        <currentPriceType>REDUCED</currentPriceType>\n
                        <comparisonPrice>\n
                            <value amount="26.79" currency="USD"/>\n
                        </comparisonPrice>\n
                    </pricing>\n
                </pricingList>\n
         </Price>\n
        </PriceFeed>\n
        """
        data = {
            "file": param.encode()
        }

        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.post(url=url, headers=hearders, data=data)
        # print(res.json())
        # print(json.dumps(res.json()))
        if res.status_code == 200:
            return json.dumps(res.json())
        else:
            print(f"接口status_code！=200 res={res.text}")

    def get_promotion_by_sku(self, orderSourceType, OrderSourceId, sku):
        url = f"https://marketplace.walmartapis.com/v3/promo/sku/{sku}"
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders)
        # print(res.json())
        # print(json.dumps(res.json()))
        if res.status_code == 200:
            return json.dumps(res.json(), indent=4)
        else:
            print(f"接口status_code！=200 res={res.text}")
            return False

    @retry(stop_max_attempt_number=100,wait_fixed=1000)
    @count_time
    def get_listing(self, orderSourceType, OrderSourceId, nextCursor, limit):
        url = f"https://marketplace.walmartapis.com/v3/items?limit={limit}&nextCursor={nextCursor}&lifecycleStatus=ACTIVE&offset=0"
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }
        try:
            res = requests.get(url=url, headers=hearders,timeout=15)
        except Exception as e:
            raise e
        if res.status_code == 200:
            # return json.dumps(res.json(),indent=4)
            return res.json()
        else:
            raise Exception(f"res.status_code!=200,erroe={res.text}")
        # else:
        #     raise HTTPRequestError(res.status_code, "HTTP request failed")

    @retry(stop_max_attempt_number=1000)
    # @count_time
    def get_listing_by_sku(self, orderSourceType, OrderSourceId, sku):
        url = f"https://marketplace.walmartapis.com/v3/items?sku={sku}"
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders)
        return res
    def get_listing_by_item_id(self, orderSourceType, OrderSourceId, item_id):
        url = f"https://marketplace.walmartapis.com/v3/items/{item_id}?productIdType=ITEM_ID"
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }

        res = requests.get(url=url, headers=hearders)
        return res
    def get_source_sku_set(self,orderSourceType, OrderSourceId):

        next_cursor = "*"
        source_sku_set = set()
        while True:
            if not next_cursor:
                break
            # 12206
            res = self.get_listing(orderSourceType, OrderSourceId, next_cursor, 1000)
            try:
                if res.get('ItemResponse'):
                    source_sku_set |= set(map(lambda x: x['sku'], res['ItemResponse']))
                    next_cursor = res.get('nextCursor')
                    print(f"source_sku_list={len(source_sku_set)}个")
            except:
                print(f"res={res}")
                raise Exception(f"self.get_listing(orderSourceType, OrderSourceId, {next_cursor}, 1000)报错")
        return source_sku_set

    # 得到描述
    def get_detail(self, orderSourceType, OrderSourceId, upc=None,gtin=None):

        url = f"https://marketplace.walmartapis.com/v3/items/walmart/search?gtin={gtin}"
        # url = f"https://marketplace.walmartapis.com/v3/items"
        hearders = {
            "WM_QOS.CORRELATION_ID": "Irobotbox",
            "WM_SVC.NAME": "Walmart Marketplace",
            "Accept": "application/json",
            "WM_SEC.ACCESS_TOKEN": get_token_by_erp(orderSourceType, OrderSourceId)
        }
        res = requests.get(url=url, headers=hearders)
        # print(res.json())
        # print(json.dumps(res.json()))
        if res.status_code == 200:
            return json.dumps(res.json())
        else:
            print(f"接口status_code！=200 res={res.text}")


if __name__ == '__main__':
    t = SycListing()
    t.get_listing_by_sku(45,23037,"7632327-land")
    # index = 0
    # while True:
    #
    #     t.get_listing(45,16130,index,1)
    #     index += 1
    # t.get_listing_by_item_id(45,20643,"5933385722")
    # # # print(t.get_status(45, 20643, "864DBFEB069E4E3AB6D2327F528E5937@AU8BCgA"))
    # # # print(t.get_detail(45, 15618, upc="3581591388601"))
    # # # print(t.create_report(45, 14674))
    # # # print(t.bulk_item(45, 20643,"MP_MAINTENANCE"))
    # # # print(t.query_status(45, 16640,"37a138f3-f64f-4c97-a885-966d44549672"))
    # # # print(t.download_report(45, 16640,"37a138f3-f64f-4c97-a885-966d44549672"))
    # # # res = t.get_listing(45, 20562, "dd6a04f0-b02e-4f96-b40f-3732405a5829", 1000, 10000)
    # # nextCursor = "*"
    # # source_sku_list= set()
    # # offset = 0
    # # while True:
    # #     if not nextCursor:
    # #         break
    # #     # 12206
    # #     res = t.get_listing(45, 20562, nextCursor,1000)
    # #     try:
    # #         if res.get('ItemResponse'):
    # #             source_sku_list |= set(map(lambda x:x['sku'], res['ItemResponse']))
    # #             nextCursor = res.get('nextCursor')
    # #             # offset += len(res['ItemResponse'])
    # #             print(f"source_sku_list={len(source_sku_list)}个")
    # #     except:
    # #         print()
    # #         raise
    # # print()